<?php  
class ControllerModuleNews extends Controller {
	protected function index($setting) {
        //$this->language->load('module/news');
        $this->data['heading_title'] = $this->language->get('heading_title');

        $this->load->model('news/news_content');

        $this->load->model('tool/image');

        $this->data['contents'] = array();

        $data = array(
            'sort'  => 'p.date_added',
            'order' => 'DESC',
            'start' => 0,
            'limit' => $setting['limit']
        );

        $results = $this->model_news_news_content->getNewes($data);

        foreach ($results as $result) {
            if ($result['image']) {
                $image = $this->model_tool_image->resize($result['image'], $setting['image_width'], $setting['image_height']);
            } else {
                $image = false;
            }


            $this->data['contents'][] = array(
                'news_id'    => $result['news_id'],
                'thumb'   	 => $image,
                'title'    	 => htmlspecialchars_decode($result['title']),
                'content'    => htmlspecialchars_decode($result['title']),
            );
        }

        if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/news.tpl')) {
            $this->template = $this->config->get('config_template') . '/template/module/news.tpl';
        } else {
            $this->template = 'phucmyquang/template/module/news.tpl';
        }
        $this->render();
	}
}
?>